<?php 
 		$sess 			= $this->session->userdata('us_');
		$cId 			= $sess['us_C'];
?>
<div id="user_setari_generale"></div>
<div id="user_setari_generale_numerotare"></div>
<script type="text/javascript">			
Ext.onReady(function(){	
	var fp_user_setari_generale;
	var fp_user_setari_generale_numerotare;
	var sID = "<?=$cId?>";
	
	fp_user_setari_generale = new Ext.FormPanel({
        frame:false,
        title:'<?=$title?> | Editare',
        bodyStyle:'padding:5px 5px 0',
		renderTo :'user_setari_generale',
        items: [
			new Ext.form.FieldSet({
	            title			:'Date companie:',
	            autoHeight		:true,
	            defaultType		:'textfield',
				items:[new Ext.form.Hidden({          
					  	fieldLabel: 'ID',  
					  	name: 'ID'
					}),
					{
		                fieldLabel: 'Nume',
						labelStyle:'width:150px;',
						width:300,
		                name: 'nume',
		                allowBlank:false
		            },{
		                fieldLabel: 'Adresa',
						labelStyle:'width:150px;',
						width:300,
		                name: 'adresa',
		                allowBlank:false
		            },{
		                fieldLabel: 'CUI',
						labelStyle:'width:150px;',
						width:300,
		                name: 'cui',
		                allowBlank:false
		            },{
		                fieldLabel: 'Nr. reg. com.',
						labelStyle:'width:150px;',
						width:300,
		                name: 'nr_reg',
		                allowBlank:false
		            },{			
		                fieldLabel: 'Banca [RON]',
						labelStyle:'width:150px;',
						width:300,
		                name: 'banca1',
		                allowBlank:false
		            },{	
		                fieldLabel: 'IBAN [RON]',
						labelStyle:'width:150px;',
						width:300,
		                name: 'iban1',
		                allowBlank:false
		            },{		
		                fieldLabel: 'Banca [EUR]',
						labelStyle:'width:150px;',
						width:300,
		                name: 'banca2'
		            },{	
		                fieldLabel: 'IBAN [EUR]',
						labelStyle:'width:150px;',
						width:300,
		                name: 'iban2'
		            },{	
		                fieldLabel: 'Stampila',
						labelStyle:'width:150px;',
						width:300,
		                name: 'stampila',
		                allowBlank:false,
						readOnly:true
		            },{		
		                fieldLabel: 'Capital',
						labelStyle:'width:150px;',
						width:300,
		                name: 'capital',
		                allowBlank:false
		            }																										
			]
			})		
		],
		listeners: {
			 'render':{
				fn: function(panel){
					panel.getForm().load({
						url:'common/selectTableWhere/' + Math.random(),                          
						waitMsg:'Loading',
						params:{saferequest:true,table:"companii",ID:sID},
						success:function(){
						}
					});	
				},
				scope:this
			}
		},
        buttons: [{
					text	:'Save',
            		tooltip	:'Salvati',
					formBind:true,
					handler : function(){
								if (fp_user_setari_generale.getForm().isValid()) {
	           						fp_user_setari_generale.getForm().submit({
									  		url: "common/updateTable/" + Math.random(),
											params:{saferequest:true,table:'companii'},
									  		waitTitle: 'Connecting..',
									  		waitMsg: 'Validating and saving data...',										
											success:function(form, action, o) {
												if(action.result.code === 0){
													Ext.MessageBox.alert('Atentie:', 'Eroare la actualizare');	
												}else if(action.result.code == 1){
														Ext.MessageBox.alert('Mesaj:', 'Actualizare efectuata cu succes!');
												}
											},										
											failure: function(form, action, o){
					                            if(action.failureType == 'server'){
					                                Ext.Msg.alert('Warning', 'Cannot save to database!', obj.errors.reason);
					                            }else{
					                                Ext.Msg.alert('Warning!', 'Authentication server is unreachable!');
					                            }
											}
								  	})
								}	
			  			}	
        		},{
					text: 'Reset',
					tooltip:'Resetati',
					handler: function(){
						fp_user_setari_generale.getForm().reset();
					}
				}]														
		
	});						
	
	fp_user_setari_generale_numerotare = new Ext.FormPanel({
        frame:false,
        title:'<?=$title?> | Vizualizare',
        bodyStyle:'padding:5px 5px 0',
		renderTo :'user_setari_generale_numerotare',
        items: [
			new Ext.form.FieldSet({
	            title			:'Numerotare:',
	            autoHeight		:true,
	            defaultType		:'textfield',
				items:[
					{
		                fieldLabel: 'Numere facturi de la',
						labelStyle:'width:150px;',
		                name: 'fact_start',
						readOnly:true
		            },{
		                fieldLabel: 'Pana la',
						labelStyle:'width:150px;',
		                name: 'fact_end',
						readOnly:true
		            },{
		                fieldLabel: 'Viitorul numar al facturii',
						labelStyle:'width:150px;',
		                name: 'fact_counter',
						readOnly:true
		            },{
		                fieldLabel: 'Numere chitante de la',
						labelStyle:'width:150px;',
		                name: 'chit_start',
						readOnly:true
		            },{	
		                fieldLabel: 'Pana la',
						labelStyle:'width:150px;',
		                name: 'chit_end',
						readOnly:true
		            },{	
		                fieldLabel: 'Viitorul numar al chitantei',
						labelStyle:'width:150px;',
		                name: 'chit_counter',
						readOnly:true
		            }																	]
			})			
		],
		listeners: {
			 'render':{
				fn: function(panel){
					panel.getForm().load({
						url:'common/selectTableWhereByCompany/' + Math.random(),                          
						waitMsg:'Loading',
						params:{saferequest:true,table:"counter"},
						success:function(){
						}
					});	
				},
				scope:this
			}
		}			
	
	});	
});
</script>
